package com.gbq.qimo.servlet;

import com.gbq.qimo.pojo.Student;
import com.gbq.qimo.pojo.Teacher;
import com.gbq.qimo.service.StudentService;
import com.gbq.qimo.service.TeacherService;
import com.gbq.qimo.service.impl.StudentServiceImpl;
import com.gbq.qimo.service.impl.TeacherServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @ClassName FindAllStudent
 * @Description TODO
 * @Author guobenqi
 * @Date 2021/5/29 17:53
 */
@WebServlet("/findAllStudents")
public class FindAllStudent extends HttpServlet {
    private StudentService studentService = new StudentServiceImpl();
    private TeacherService teacherService = new TeacherServiceImpl();
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       List<Student> studentList = studentService.findAllStudents();
       request.setAttribute("studentList",studentList);
        List<Teacher> teacherList = teacherService.findAllTeacher();
        request.setAttribute("teacherList",teacherList);
       request.getRequestDispatcher("/admin.jsp").forward(request,response);
    }
}
